﻿@using System;
@using Destiny.Core.Flow.CodeGenerator;
@{

    ProjectMetadata metadata = Model;
    var userKeyType = metadata.EntityMetadata.AuditedUserKeyType;
    string auditedOrSoft = string.Empty;
    if (metadata.EntityMetadata.IsFullAudited())
    {
        auditedOrSoft = $"{auditedOrSoft}, IFullAuditedEntity<{userKeyType}>";
    }
    else
    {
        if (metadata.EntityMetadata.IsCreation)
        {
            auditedOrSoft = $"{auditedOrSoft}, ICreationAudited<{userKeyType}>";
        }
        if (metadata.EntityMetadata.IsModification)
        {

            auditedOrSoft = $"{auditedOrSoft}, IModificationAudited<{userKeyType}>";
        }
        if (metadata.EntityMetadata.IsSoftDelete)
        {
            auditedOrSoft = $"{auditedOrSoft}, ISoftDelete";
        }
    }


}
using System;
using System.Collections.Generic;
using System.ComponentModel;
using Destiny.Core.Flow.Entity;
namespace @(metadata.Namespace).Entities
{

    /// &lt;summary&gt;
    /// @(string.IsNullOrEmpty(metadata.EntityMetadata.DisplayName) ? metadata.EntityMetadata.EntityName : metadata.EntityMetadata.DisplayName)
    /// &lt;/summary&gt;
    [DisplayName("@(metadata.EntityMetadata.DisplayName)")]
    public partial class @metadata.EntityMetadata.EntityName : EntityBase&lt;@(metadata.EntityMetadata.PrimaryKeyType)&gt;@auditedOrSoft
    {
    @foreach (var property in metadata.EntityMetadata.Properties.Where(o => !o.IsPrimaryKey))
    {

        @:/// &lt;summary&gt;
        @:/// 获取或设置 @property.DisplayName
        @:/// &lt;/summary&gt;
        @:[DisplayName("@property.DisplayName")]
        @:public @(string.IsNullOrEmpty(property.AggregateType)?TypeHelper.ToSingleTypeName(property.CSharpType,property.IsNullable):TypeHelper.GetAggregate(property.AggregateType,property.CSharpType,property.IsNullable)) @property.PropertyName { get; set; }
    }
    @{
        if (metadata.EntityMetadata.IsFullAudited())
        {
        @:/// &lt;summary&gt;
        @:/// 获取或设置最后修改用户
        @:/// &lt;/summary&gt;
        @:[DisplayName("最后修改用户")]
        @:public @metadata.EntityMetadata.AuditedUserKeyType? LastModifierUserId { get; set; }

        @:/// &lt;summary&gt;
        @:/// 获取或设置最后修改时间
        @:/// &lt;/summary&gt;
        @:[DisplayName("最后修改时间")]
        @:public DateTime? LastModifionTime { get; set; }

        @:/// &lt;summary&gt;
        @:/// 获取或设置是否删除
        @:/// &lt;/summary&gt;
        @:[DisplayName("是否删除")]
        @:public bool IsDeleted { get; set; }

        @:/// &lt;summary&gt;
        @:/// 获取或设置创建用户ID
        @:/// &lt;/summary&gt;
        @:[DisplayName("创建用户ID")]
        @:public @metadata.EntityMetadata.AuditedUserKeyType? CreatorUserId { get; set; }

        @:/// &lt;summary&gt;
        @:/// 获取或设置创建时间
        @:/// &lt;/summary&gt;
        @:[DisplayName("创建时间")]
        @:public DateTime CreatedTime { get; set; }
        }
        else
        {
            if (metadata.EntityMetadata.IsCreation)
            {
        @:/// &lt;summary&gt;
        @:/// 获取或设置创建用户ID
        @:/// &lt;/summary&gt;
        @:[DisplayName("创建用户ID")]
        @:public @metadata.EntityMetadata.AuditedUserKeyType? CreatorUserId { get; set; }
        
        @:/// &lt;summary&gt;
        @:/// 获取或设置创建时间
        @:/// &lt;/summary&gt;
        @:[DisplayName("创建时间")]
        @:public DateTime CreatedTime { get; set; }
        }
        if (metadata.EntityMetadata.IsModification)
        {
        @:/// &lt;summary&gt;
        @:/// 获取或设置最后修改用户
        @:/// &lt;/summary&gt;
        @:[DisplayName("最后修改用户")]
        @:public @metadata.EntityMetadata.AuditedUserKeyType? LastModifierUserId { get; set; }
        
        @:/// &lt;summary&gt;
        @:/// 获取或设置最后修改时间
        @:/// &lt;/summary&gt;
        @:[DisplayName("最后修改时间")]
        @:public DateTime? LastModifionTime { get; set; }
        }
        if (metadata.EntityMetadata.IsSoftDelete)
        {
        @:/// &lt;summary&gt;
        @:/// 获取或设置是否删除
        @:/// &lt;/summary&gt;
        @:[DisplayName("是否删除")]
        @:public bool IsDeleted { get; set; }
            }
        }


    }

    }
}
